package com.wenx.util;

import java.util.concurrent.RecursiveAction;

/**
 * Created by Think on 2018/11/25.
 */
public abstract class AbstractDataLoader<T> extends RecursiveAction implements IDataLoader{

    //这里就是用来保存返回的结果，由业务防自己在实现的load()方法中写入数据
    protected T context;

    public AbstractDataLoader(T context){
        this.context = context;
    }

    public void compute(){
        load(context);
    }

    /**
     * 获取执行后的结果，强制等待执行完毕
     * @return T
     */
    public T getContext(){
        this.join();
        return context;
    }

    public void setContext(T context) {
        this.context = context;
    }

}
